if [ -n "$1" ]; then
    data_date=$1
else
  data_date=`date -d "-1 day" +%F`
fi

sqoop import \
--connect jdbc:mysql://node101:3306/06_gongdan \
--username root \
--password 123456 \
--as-textfile \
--fields-terminated-by '\001' \
--query 'SELECT sale_id,product_id,sale_date,sale_amount,quantity,customer_id,order_id,payment_method,status FROM ods_sale_log WHERE $CONDITIONS AND 1=1' \
--target-dir "hdfs://node101:8020/user/hive/warehouse/jtp_gd06_warehouse/ods_sale_log/dt=${data_date}" \
--delete-target-dir \
--null-non-string '\\N' \
--null-string '\\N' \
--num-mappers 1

sqoop import \
--connect jdbc:mysql://node101:3306/06_gongdan \
--username root \
--password 123456 \
--as-textfile \
--fields-terminated-by '\001' \
--query 'SELECT category_id,category_name FROM ods_product_type_dim_tb WHERE $CONDITIONS AND 1=1' \
--target-dir "hdfs://node101:8020/user/hive/warehouse/jtp_gd06_warehouse/ods_product_type_dim_tb/dt=${data_date}" \
--delete-target-dir \
--null-non-string '\\N' \
--null-string '\\N' \
--num-mappers 1

sqoop import \
--connect jdbc:mysql://node101:3306/06_gongdan \
--username root \
--password 123456 \
--as-textfile \
--fields-terminated-by '\001' \
--query 'SELECT launch_id,product_id,launch_date,launch_type,main_image_url,title,sku FROM ods_product_log WHERE $CONDITIONS AND 1=1' \
--target-dir "hdfs://node101:8020/user/hive/warehouse/jtp_gd06_warehouse/ods_product_log/dt=${data_date}" \
--delete-target-dir \
--null-non-string '\\N' \
--null-string '\\N' \
--num-mappers 1

sqoop import \
--connect jdbc:mysql://node101:3306/06_gongdan \
--username root \
--password 123456 \
--as-textfile \
--fields-terminated-by '\001' \
--query 'SELECT product_id,product_name,category_id,brand_id,price,description,is_new,launch_date,status FROM ods_product_dim_tb WHERE $CONDITIONS AND 1=1' \
--target-dir "hdfs://node101:8020/user/hive/warehouse/jtp_gd06_warehouse/ods_product_dim_tb/dt=${data_date}" \
--delete-target-dir \
--null-non-string '\\N' \
--null-string '\\N' \
--num-mappers 1

sqoop import \
--connect jdbc:mysql://node101:3306/06_gongdan \
--username root \
--password 123456 \
--as-textfile \
--fields-terminated-by '\001' \
--query 'SELECT customer_id,customer_name,customer_email,customer_phone,customer_level,registration_date FROM ods_customer_dim_tb WHERE $CONDITIONS AND 1=1' \
--target-dir "hdfs://node101:8020/user/hive/warehouse/jtp_gd06_warehouse/ods_customer_dim_tb/dt=${data_date}" \
--delete-target-dir \
--null-non-string '\\N' \
--null-string '\\N' \
--num-mappers 1